Create custom action msg
Table of Content
Actions are defined in .action locate in action sub folder
Action files defined in this structure
# Request
---
# Result
---
# Feedback
Demo#
Action Definition#
action/MyAction.action
int32 count
---
int32 total
---
int32 current
CMakeLists#
CMakeList.txt
cmake_minimum_required(VERSION 3.8)
project(action_tutorial_interfaces)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rosidl_default_generators REQUIRED)
rosidl_generate_interfaces(${PROJECT_NAME}
"action/MyAction.action"
)
ament_package()
CMakeLists
Keep each action in new line
Package.xml#
Add to package.xml
<buildtool_depend>rosidl_default_generators</buildtool_depend>
<depend>action_msgs</depend>
<member_of_group>rosidl_interface_packages</member_of_group>
build and test#
colcon build --packages-select action_tutorial_interfaces
checkros2 interface show action_tutorial_interfaces/action/MyAction
#
int32 count
---
int32 total
---
int32 current
#
ros2 interface show action_tutorial_interfaces/action/MyAction
#
int32 count
---
int32 total
---
int32 current